#!/usr/bin/env bash
# Copyright (c) Open Enclave SDK contributors.
# Licensed under the MIT License.

# shellcheck disable=SC2068
# llvm-arw is a wrapper over llvm-ar. It converts Windows style 
# directory separator (\) to Linux style directory separator (/) 
# in any response files.

function call_llvmar {
    args=()

    # Transform any response file.
    for a; do
        # Response files start with an @
        if [[ "$a" == \@* ]]; then
            # Transform directory separators within the response file.
            sed -i 's/\\/\//g' "${a:1}"
        fi

        args+=("$a ")
    done

    # Replace \ by / in each argument
    args+=("$a ")
    llvm-ar ${args[@]}
}
# shellcheck disable=SC2068
call_llvmar $@
